/*
 * @Author: your name
 * @Date: 2021-11-22 16:02:34
 * @LastEditTime: 2024-04-25 16:10:10
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \agricultural-production-web\src\main.js
 */
import Vue from 'vue';

import 'normalize.css/normalize.css'; // A mod/ern alternative to CSS resets

import 'element-ui/lib/theme-chalk/index.css';

import '@/styles/index.scss'; // global css

import App from './App';
import store from './store';
import router from './router';

import '@/icons'; // icon

import i18n from './lang';
import Cookies from 'js-cookie';
import Element from 'element-ui';
// 引入echarts
// import * as echarts from "echarts";
// Vue.prototype.$echarts = echarts;
import { dateToFormat, dateToFormattwo, dateToFormatname, dateToFormatthree, toLocal } from '@/utils/validate';
Vue.prototype.dateToFormat = dateToFormat;
Vue.prototype.dateToFormattwo = dateToFormattwo;
Vue.prototype.dateToFormatname = dateToFormatname;
Vue.prototype.dateToFormatthree = dateToFormatthree;
Vue.prototype.toLocal = toLocal;

// 统一大的请求地址

import $baseurl from '@/api/baseURL';
Vue.prototype.$cloudBaseurl = $baseurl.cloudBaseurl;
Vue.prototype.$baseurl = $baseurl;
Vue.prototype.$webSerUrl = $baseurl.webUrl;

import { webServiceUrl } from '@/api/baseURL';
Vue.prototype.$webServiceUrl = webServiceUrl;

import * as $utils from '@/utils/index';
Vue.prototype.$utils = $utils;

import Print from 'vue-print-nb'; // 打印
Vue.use(Print); // 注册
// 引入农场类型选择公用组件
// import FarmTypeSelect from '@/components/FarmTypeSelect'
// Vue.component('farm-type-select', FarmTypeSelect)

import BaiduMap from 'vue-baidu-map';
Vue.use(BaiduMap, {
  /* 需要注册百度地图开发者来获取你的ak */
  ak: 'sKrOZGXxifZ1r7Ot7Bm1OoBWd6DILGfH'
});

// 图片
import EleUploadImage from 'vue-ele-upload-image';
Vue.component(EleUploadImage.name, EleUploadImage);

import CommonBtn from '@/components/Btn/index';
Vue.component('CommonBtn', CommonBtn);

import moment from 'moment'; // 导入moment模块
moment.locale('zh-cn'); // 设置语言 或 moment.lang('zh-cn');
Vue.prototype.$moment = moment; // 赋值使用

// 禁止点击空白关闭
Element.Dialog.props.closeOnClickModal.default = false;
//  以上级元素为大小
Element.Dialog.props.modalAppendToBody.default = false;
// 禁止点击空白关闭
Element.Dialog.props.modal.default = false;
// console.log(Element.Dialog.props)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
});
// passive警告
// import 'default-passive-events';
// 清除生产环境console.log
console.log = (function(log) {
  // eslint-disable-next-line eqeqeq
  return process.env.NODE_ENV == 'development' ? log : function() {};
})(console.log);

Vue.prototype.$hasSlot = function(name = 'default') {
  return !!this.$slots[name] || !!this.$scopedSlots[name];
};
Vue.prototype.dateToFormatTwo = function(originDate, format) {
  const dt = new Date(originDate);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2, '0');
  const d = (dt.getDate() + '').padStart(2, '0');
  if (format) {
    return moment(originDate).format(format);
  } else {
    return `${y}-${m}-${d}`;
  }
};
Vue.config.productionTip = false;
import frameInRoutes from '@/router/routes';
import '@/permission'; // permission control
import './assets/iconfont/iconfont.css';

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  created() {
    // 处理路由 得到每一级的路由设置
    this.$store.commit('page/init', frameInRoutes);
  },
  render: h => h(App)
});
